package com.project.webapp.action.front.preSchool;

import java.util.ArrayList;
import java.util.List;

import com.project.common.Constants;
import com.project.dao.bean.Menu;
import com.project.service.front.preSchool.IPreSchoolService;
import com.project.webapp.action.BaseAction;
import com.project.webapp.form.front.preSchool.PreSchoolForm;

/**
 * 无忧在学期
 * 
 * @author lantian
 * @version $Id: PreSchoolAction.java, v 0.1 2012-9-21 下午02:38:12 lantian Exp $
 */
public class PreSchoolAction extends BaseAction {
	private IPreSchoolService preSchoolService;
	private PreSchoolForm preSchoolForm;
	/**
	 * 第一级目录
	 */
	private List<Menu> menuLevelList1;
	/**
	 * 第二级目录
	 */
	private List<Menu> menuLevelList2;

	/**
	 * 课程tab
	 */
	private List<Menu> courseList;

	/**
	 * <pre>
	 * 
	 * </pre>
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public String execute() throws Exception {
		try {
			List<Menu> menuLevelList = preSchoolService
					.getMenuByCondition(preSchoolForm);
			if (menuLevelList != null) {
				menuLevelList1 = new ArrayList<Menu>();
				menuLevelList2 = new ArrayList<Menu>();
				for (Menu m : menuLevelList) {
					if (m.getMenuSeq() == 1) {
						menuLevelList1.add(m);
					} else if (m.getMenuSeq() == 2) {
						menuLevelList2.add(m);
					}
				}
			}
			
			//获取课程tab list
			courseList = preSchoolService.getMenuForCourse(Constants.MENU_COURSE);
			if(courseList.size()<70){
				for(int i=0 ;i< 70- courseList.size();i++){
					courseList.add(new Menu());
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

		return SUCCESS;
	}

	public List<Menu> getMenuLevelList1() {
		return menuLevelList1;
	}

	public void setMenuLevelList1(List<Menu> menuLevelList1) {
		this.menuLevelList1 = menuLevelList1;
	}

	public void setPreSchoolService(IPreSchoolService preSchoolService) {
		this.preSchoolService = preSchoolService;
	}

	public PreSchoolForm getPreSchoolForm() {
		return preSchoolForm;
	}

	public void setPreSchoolForm(PreSchoolForm preSchoolForm) {
		this.preSchoolForm = preSchoolForm;
	}

	public List<Menu> getMenuLevelList2() {
		return menuLevelList2;
	}

	public void setMenuLevelList2(List<Menu> menuLevelList2) {
		this.menuLevelList2 = menuLevelList2;
	}

	public List<Menu> getCourseList() {
		return courseList;
	}

	public void setCourseList(List<Menu> courseList) {
		this.courseList = courseList;
	}

}
